//
//  UIButton+YTLayout.m
//  yangtao
//
//  Created by Tommy on 14/10/17.
//  Copyright (c) 2014年 com.taobao. All rights reserved.
//

#import "UIButton+KLImageTitleLayout.h"

@implementation UIButton (KLImageTitleLayout)
- (void)layoutVertical{
    [self layoutVertical:8.0];
}
- (void)layoutVertical:(CGFloat)spacing{
    // the space between the image and text
    // lower the text and push it left so it appears centered
    //  below the image
    CGSize imageSize = self.imageView.frame.size;
    self.titleEdgeInsets = UIEdgeInsetsMake(0.0, - imageSize.width, - (imageSize.height + spacing), 0.0);
    
    // raise the image and push it right so it appears centered
    //  above the text
    CGSize titleSize = self.titleLabel.frame.size;
    self.imageEdgeInsets = UIEdgeInsetsMake(- (titleSize.height + spacing), 0.0, 0.0, - titleSize.width);
}

@end
